{include file="common/top" /}

<div style="padding: 20px;background: #ffffff;" >
	<form class="layui-form " action="">
	<div class="layui-form-item">
		<label class="layui-form-label">*小组名称：</label>
		<div class="layui-col-xs4">
			<input type="text" name="name" value="{$rs.name}" lay-verify="required" autocomplete="off" placeholder="请输入小组名称" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">*组长：</label>
		<div class="layui-col-xs4">
			<select name="leader"  autocomplete="off" lay-filter="aihao">
				<option value="">请选择组长</option>
				{volist name="acc_list" id='vo'}
					<option value="{$vo.id}" {eq name="rs.leader" value="$vo.id"}selected{/eq}>{$vo.username}</option>
				{/volist}
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">*成员：</label>
		<div class="layui-col-xs8">
			<div id="demo1" ></div>
		</div>
	</div>
	<hr />
	<div class="layui-form-item">
		<div class="layui-input-block">
            <input type="hidden" name="id" value="{$rs.id}"  >
			<button class="layui-btn"  lay-submit="" lay-filter="demo1">修改</button>
		</div>
	</div>
	
	</form>
	
</div>
<script src="__static/js/xm-select.js" charset="utf-8"></script>
{include file="common/footer" /}
<script>
	var form ,layer ,$ ;
	
	layui.use(['form', 'layedit', 'laydate'], function(){
		  form = layui.form ,layer = layui.layer ,$ = layui.$;
		
	
		  //监听提交
		  form.on('submit(demo1)', function(data){
			var articleFrom = data.field;
			layer.load(1, { shade : [ 0.5, '#676a6c' ] });
			$.post("{:url('group_save')}?t=json",articleFrom,function(data){
				layer.closeAll();
				if (data['code'] == 1) {
					var index1 = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
					parent.layer.close(index1); //再执行关闭 
					//父页面数据 ，重新加载
					parent.get_s(data['msg']);

				} else {
					layer.msg(data['msg'], { icon : 5 });
				}
			});
			
			return false;
		  });
		
		get_yy()
		var demo1;
		function get_yy(){
			layer.load(1, { shade : [ 0.5, '#676a6c' ] });
			$.post("{:url('get_yy_list')}?t=json",{},function(data){
				layer.closeAll();
				if (data['code'] == 1) {
					demo1 = xmSelect.render({
						el: '#demo1', 
						toolbar: {
							show: true,
							showIcon: false,
						},
						name:'member',
						data: data.data
                    })
                    
                    demo1.setValue([  {$rs.member}]);
				} else {
					layer.msg(data['msg'], { icon : 5 });
				}
			});
		}
		form.on('select(aihao)', function(data){
			demo1.setValue([ data.value ]);
        }); 
       
	});
	
	
</script>
